#include <head.h>

uint32_t stringIPtoNum(char *pIP)
{
    uint32_t nIP = 0;
    // AF_INET是代表IPV4地址的意思，AF_INET6代表IPV6
    inet_pton(AF_INET, pIP, &nIP);
    return nIP;
}

// 把数字IP转为字符串IP
void numIPtoString(uint32_t ip, char *psIP, int size)
{
    inet_ntop(AF_INET, &ip, psIP, size);
}



int main()
{
    int fd = socket(AF_INET, SOCK_DGRAM, 0);
    if (-1 == fd)
    {
        perror("socket");
    }
    
    struct sockaddr_in addr;
    addr.sin_addr.s_addr = stringIPtoNum("192.168.70.37");
    addr.sin_port = htons(8888);
    addr.sin_family = AF_INET;
    char buf[1024] = "baodao";
    sendto(fd,buf,sizeof(buf),0,(struct sockaddr *)&addr,sizeof(addr));
    
    while (1)
    {
        char buf[1024];
        scanf ("%s",buf);
        sendto(fd,buf,sizeof(buf),0,(struct sockaddr *)&addr,sizeof(addr));

    }
    return 0;
}
